<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="javabean.*"%>
<%@page import="javabean.user.*"%>
<%
	String sUserName = (String) session.getAttribute("uname");
	String sUserId = (String) session.getAttribute("uid");
	String sUserPic =(String) session.getAttribute("upic");
	String servletPath = request.getServletPath();
	String homeActive = "" ,groupActive = "", aboutActive = "";
	String showName = "";
	if(sUserName!=null){
		showName = sUserName ;
	}else{
		showName = sUserId;
	}
	if(servletPath.indexOf("group")!= -1){
		groupActive = "active";
	}else if(servletPath.indexOf("about") != -1){
		aboutActive = "active";
	}else{
		homeActive = "active";
	}
%>
<header class="navbar navbar-default navbar-fixed-top my-navbar" role="navigation">
	<%if(sUserId!=null){%>
		<input type="hidden" class="hidden-session" value="<%=sUserId %>"/>
	<%} %>
	<div class="container head-container">
		<div class="navbar-header bc-navbar-header">
			<a href="/bookcrossing/"><img src="/bookcrossing/img/logo.png" alt="logo"></a>
		</div>
		<div class="collapse navbar-collapse bc-navbar-collapse">
			<ul class="nav navbar-nav">
				<li class="<%=homeActive %>">
					<a href="/bookcrossing/">首页</a>
				</li>
				<li class="<%=groupActive %>">
					<a href="/bookcrossing/group">漂流圈</a>
				</li>
				<li class="<%=aboutActive %>">
					<a href="/bookcrossing/about">关于</a>
				</li>
			</ul>
			<form id="search-form" class="navbar-form navbar-left" role="search" action="/bookcrossing/search" >
				<div class="input-group">
					<input type="text" class="form-control search-input" name="keyword" placeholder="ISBN、书名、作者"/>
					<span class="input-group-btn">
						<button type="submit" class="btn btn-info">
							<span class="glyphicon glyphicon-search"></span>
						</button>
					</span>
				</div>
			</form>
			<ul class="nav navbar-nav navbar-right">
			<%if(showName!=null && !"".equals(showName)){%>
				<li>
					<a href="/bookcrossing/user/profile?uid=<%=sUserId %>" title="<%=showName %>">
					<span class="user-show"><img src="/bookcrossing/img/user/<%=sUserPic %>"/></span>
					<%
						byte[] s = showName.getBytes();
						if(s.length>8){
					%>
						<%=new String(s,0,8)+"..."%>
					<%}else{ %>
						<%=showName %>
					<%} %>
					
					</a>
				</li>
				<li>
					<a href="/bookcrossing/book/add" title="发布新书"><span class="glyphicon glyphicon-plus"></span></a>
				</li>
				<li class="dropdown">
					<a href="#" class="dropdown-toggle" data-toggle="dropdown">
						<span class="glyphicon glyphicon-envelope"></span>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li>
							<a href="#">通知</a>
						</li>
						<li>
							<a href="#">私信</a>
						</li>
					</ul>
				</li>
				<li>
					<a href="#" class="dropdown-toggle" data-toggle="dropdown">
						<span class="glyphicon glyphicon-cog"></span>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li>
							<a href="/bookcrossing/user/info">修改个人资料</a>
						</li>
						<li>
							<a href="/bookcrossing/logout" class="logout">退出</a>
						</li>
					</ul>
				</li>
			<%}else{ %>
				<li>
					<a href="/bookcrossing/login">登陆</a>
				</li>
				<li>
					<a href="/bookcrossing/reg">注册</a>
				</li>
			<%} %>
			</ul>
		</div>
	</div>
</header>
